Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(import/extensions): allow enforcement decision overrides based on specifier #3105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Xunnamius
Copy link

@Xunnamius Xunnamius commented Nov 19, 2024

I already use import/order with custom pathGroups. This allows me to control the grouping of certain paths, such as custom aliases from tsconfig.json's paths. This in turn ensures all imports are sorted properly, even when the project is using syntactically sound but otherwise bespoke custom aliases like my-project:api.js (in lieu of ../../../../src/api.js).

Unfortunately, if I mistype my-project:api (i.e. I forgot the extension), the import/extensions rule will still pass; the enforcement decision is "ignore" when it should have been "enforce". This is because, like import/order, the grouping strategy employed by this rule is quite coarse-grained, but unlike import/order, this rule is missing a pathGroups-like setting for finer-grained sorting. The goal of this PR is to fill that gap.

This PR allows developers to override the decision to enforce or ignore extensions for imports with matching specifiers. This is implemented via pathGroupOverrides.

The documentation updates associated with the changes in this PR are part of a separate PR and can be previewed here (towards the bottom of the section). This PR also includes tests.

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.23%. Comparing base (a20d843) to head (1c127b7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3105      +/-   ##
==========================================
- Coverage   95.28%   95.23%   -0.05%     
==========================================
  Files          83       83              
  Lines        3584     3592       +8     
  Branches     1252     1257       +5     
==========================================
+ Hits         3415     3421       +6     
- Misses        169      171       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant